<!DOCTYPE html>
<html>
<head>
<script src="../editing.js"></script>
<script src="../../resources/dump-as-markup.js"></script>
<script>
Markup.description("This tests that image alt text makes it to the clipboard. This test requires DRT or WTR."
    + " The first two dumps should not include alt text and the third and forth dumps should include alt text.");
Markup.noAutoDump();

function runTest()
{
    var test = document.getElementById("test");
    execSetSelectionCommand(test, 0, test.nextSibling, 0);
    execCopyCommand();

    document.getElementById("textarea-result").value = "";
    document.getElementById("textarea-result").focus();
    execPasteCommand();
    Markup.dump("textarea-result");

    document.getElementById("content-editable-result").innerHTML = "";
    selection.collapse(document.getElementById("content-editable-result"), 0);
    execPasteAndMatchStyleCommand();
    Markup.dump("content-editable-result");
}

window.onload = function()
{
    if (window.testRunner)
        testRunner.dumpAsText();

    if (window.internals)
        internals.settings.setSelectionIncludesAltImageText(false);
    runTest();
    if (window.internals)
        internals.settings.setSelectionIncludesAltImageText(true);
    runTest();

    Markup.notifyDone();
};
</script>
</head>
<body>

<div id="test">Here is an emoticon [<img src="resources/apple.gif" alt=":)">],
some more text [<img alt="sample text">],
an empty alt tag [<img alt="">],
no alt tag [<img src="resources/apple.gif">]
and two consecutive images [<img src="resources/apple.gif" alt="first"><img src="resources/apple.gif" alt="second">].</div>
<textarea id="textarea-result" style="width: 100%; height: 5em;"></textarea>
<div id="content-editable-result" contentEditable="true"></div>
</body>
</html>
